import React from 'react'
import { Row, Col, Form } from 'antd'
import PropTypes from 'prop-types'
import style from './block.module.less'
import PartyList from './PartyList/Index'
import AgentList from './AgentList/Index'
import { CaseContext } from '../context'
const { Item } = Form
function Main ({ caseFormRef, forzen }) {
  return (
    <CaseContext.Consumer>
      {({ isPre }) => (
        <>
          <Row>
            <Col span={4} className={style['block-title']}><span>当事人信息</span></Col>
            <Col span={2} />
            <Col span={10}>
              <Item label='申请人' name='applicants' rules={[{ required: true, message: '申请人不能为空' }]}>
                <PartyList type='申请人' caseFormRef={caseFormRef} forzen={forzen} />
              </Item>
            </Col>
          </Row>
          {!isPre ? (
            <Row>
              <Col span={6} />
              <Col span={10}>
                <Item label='代理人' name='applicant_agents'>
                  <AgentList type='申请人' caseFormRef={caseFormRef} forzen={forzen} />
                </Item>
              </Col>
            </Row>
          ) : null}
          <Row>
            <Col span={6} />
            <Col span={10}>
              <Item label='被申请人' name='respondents' rules={[{ required: true, message: '被申请人不能为空' }]}>
                <PartyList type='被申请人' caseFormRef={caseFormRef} forzen={forzen} />
              </Item>
            </Col>
          </Row>
          {!isPre ? (
            <Row>
              <Col span={6} />
              <Col span={10}>
                <Item label='代理人' name='respondents_agents'>
                  <AgentList type='被申请人' caseFormRef={caseFormRef} forzen={forzen} />
                </Item>
              </Col>
            </Row>
          ) : null}
        </>
      )}
    </CaseContext.Consumer>
  )
}

Main.propTypes = {
  caseFormRef: PropTypes.object,
  forzen: PropTypes.bool
}

Main.defaultProps = {
  caseFormRef: null,
  forzen: false
}

export default Main
